<template>
	<!-- VIP岗位 -->
	<view class="p20r">
		<u-form :model="form" ref="uForm">
			<view class="pl20r pr20r bor-rad14r" style="background-color: #fff;">
				<u-form-item label-width="auto" label="姓名">
					<u-input input-align="right" v-model="form.name" placeholder="请输入你的姓名" :clearable='false' />
				</u-form-item>
				<u-form-item label-width="auto" label="性别">
					<u-input input-align="right" v-model="form.gender" @tap='setgender' disabled
						placeholder="请选择你的性别" />
					<view class="cuIcon-right" slot="right" @tap='setgender'></view>
				</u-form-item>
				<u-form-item label-width="auto" label="年龄">
					<u-input input-align="right" v-model="form.age" placeholder="请输入你的年龄" :clearable='false' />
				</u-form-item>
				<u-form-item label-width="auto" label="民族">
					<u-input input-align="right" v-model="form.nation" placeholder="请输入你的民族" :clearable='false' />
				</u-form-item>
				<u-form-item label-width="auto" label="出生日期">
					<u-input input-align="right" v-model="form.birthday" @tap="show=true" disabled
						placeholder="请选择你的生日" />
					<view class="cuIcon-right" @tap="show=true" slot="right"></view>
				</u-form-item>
				<u-form-item label-width="auto" label="联系电话">
					<u-input input-align="right" v-model="form.iphone" placeholder="请输入你的联系电话" :clearable='false' />
				</u-form-item>
				<u-form-item label-width="auto" label="学历">
					<u-input input-align="right" v-model="form.education" @tap='educationShow=true' disabled
						placeholder="请选择你的学历" />
					<view class="cuIcon-right" slot="right" @tap='educationShow=true'></view>
				</u-form-item>
				<u-form-item label-width="auto" label="毕业学校">
					<u-input input-align="right" v-model="form.graduation_school" placeholder="请输入你的毕业学校"
						:clearable='false' />
				</u-form-item>
				<u-form-item label-width="auto" label="专业">
					<u-input input-align="right" v-model="form.major" placeholder="专业" :clearable='false' />
				</u-form-item>
				<u-form-item label-width="auto" label="工作经历" label-position="top">
					<view class="bg-eee w-max p20r pb0">
						<u-input v-model="form.work_experience" type="textarea" placeholder="请输入你的工作经历（不超过500字）"
							:auto-height="true" maxlength="500" input-align="left" style="text-align: left;" />
						<view class="tr">{{form.work_experience.length||0}}/500</view>
					</view>
				</u-form-item>
				<u-form-item label-width="auto" label="教育经历" label-position="top">
					<view class="bg-eee w-max p20r pb0">
						<u-input v-model="form.educational_experience" type="textarea" placeholder="请输入你的工作经历（不超过500字）"
							:auto-height="true" maxlength="500" input-align="left" style="text-align: left;" />
						<view class="tr">{{form.educational_experience.length||0}}/500</view>
					</view>
				</u-form-item>
			</view>
			<view class="pl20r pr20r mt20 bor-rad14r" style="background-color: #fff;">
				<u-form-item label-width="auto" label="意向岗位">
					<u-input input-align="right" v-model="form.intended_position" placeholder="请输入意向岗位" />
					<!-- <view class="cuIcon-right" slot="right"></view> -->
				</u-form-item>
				<u-form-item label-width="auto" label="意向工作区域">
					<u-input input-align="right" v-model="form.intended_work_area" placeholder="请输入意向工作区域" />
					<!-- <view class="cuIcon-right" slot="right"></view> -->
				</u-form-item>
				<u-form-item label-width="auto" label="意向最低薪酬">
					<u-input input-align="right" v-model="form.intended_salary" placeholder="请输入意向最低薪酬" />
				</u-form-item>
				<u-form-item label-width="auto" label="意向最高薪酬">
					<u-input input-align="right" v-model="form.intended_salary_end" placeholder="请输入意向最高薪酬" />
				</u-form-item>
				<u-form-item label-width="auto" label="预计入职时间">
					<u-input input-align="right" v-model="form.estimated_entry_time" @tap="showRz=true" disabled
						placeholder="请选择入职时间" />
					<view class="cuIcon-right" slot="right" @tap="showRz=true"></view>
				</u-form-item>
				<u-form-item label-width="auto" label="求职状态">
					<u-input input-align="right" v-model="form.job_status" disabled @tap="setstatus"
						placeholder="请选择求职状态" />
					<view class="cuIcon-right" slot="right" @tap="setstatus"></view>
				</u-form-item>
				<block v-for="(item,i) in TemplateList" :key='i'>
					<u-form-item label-width="auto" :label="item.title">
						<u-input input-align="right" v-model="item.key" placeholder="请输入内容" :clearable='false'
							:type="item.category" />
					</u-form-item>
				</block>
			</view>
		</u-form>
		<view class="x-c bg-zs bor-rad14r h100r color-fff mt50r" @tap="submit">提交</view>
		<u-picker mode="time" @confirm="setTime" v-model="show"></u-picker>
		<u-picker mode="time" @confirm="setTimeRz" v-model="showRz"></u-picker>
		<!-- 学历 -->
		<u-select v-model="educationShow" label-name='name' value-name='id' @confirm="seteducation" :list="educationL">
		</u-select>
	</view>
</template>

<script>
	export default {
		name: 'vipJob',
		data() {
			return {
				show: false,
				showRz: false, //入职时间
				educationShow: false, //学历
				educationL: [], //学历
				form: {
					name: '', //姓名
					gender: '', //性别
					age: '', //年纪
					nation: '', //民族
					birthday: '', //生日
					iphone: '', //联系电话
					education: '', //学历
					graduation_school: '', //毕业院校
					major: '', //专业
					work_experience: '', //工作经历
					educational_experience: '', //教育经历
					intended_position: '', //意向岗位
					intended_work_area: '', //意向工作区域		
					intended_salary: '', //意向薪酬起
					intended_salary_end: '', //意向薪酬始
					estimated_entry_time: '', //预计入职时间
					job_status: '', //求职状态
					json: '',
					id: '' ,//VIP岗位列表id （修改的时候必传 （添加的时候不用传））
					async:''
				},
				type: '',
				state: '',
				TemplateList: []
			};
		},
		onLoad(e) {
			// console.log('000',e)
			if (e.index) {
				this.form.id = e.index
			}
			if (e.type) {
				this.type = e.type
			}
			if (e.state == '修改') {
				this.state = e.state
				uni.setNavigationBarTitle({
					title: '修改申请'
				})
				let routes = getCurrentPages() //判断是不是在登录页
				let curRoute = routes[routes.length - 2].data[e.index]
				console.log(curRoute)
				this.form = curRoute
			}
			this.geteducation() //获取学历
			this.getmyResumeInfo() //获取我的简历自定义模板
		},
		onNavigationBarButtonTap() {
			if (this.state != '修改') {
				this.$jump('/pages/home/recruit/vipJob/historyOrder/historyOrder?type=' + this.type)
			} else {
				this.$msg('修改订单无法查看历史订单')
			}

		},
		methods: {
			//获取我的简历自定义模板
			getmyResumeInfo() {
				this.$api.myResumeInfo().then(res => {
					console.log('111', res)
					this.TemplateList = res.data.map(item => {
						item.key = ''
						return item
					})
				})
			},
			setstatus() {
				let that = this
				//请选择在职/离职状态
				let itemList = ['在职', '离职']
				uni.showActionSheet({
					itemList,
					success(res) {
						that.form.job_status = itemList[res.tapIndex]
					}
				})
			},
			async submit() {
				// let obj = {}
				console.log('333',this.TemplateList)
				this.form.json=JSON.stringify(this.TemplateList)
				// console.log('55',this.form)
				// return
				// await this.TemplateList.map(item => {
				// 	obj[item.abc] = item.abc
				// })
				// let form = await Object.assign({}, this.form, obj)
				let api
				if (this.type == 1) {
					api = 'recruitsVipSubmit'
				} else if (this.type == 3) {
					api = 'internshipVipSubmit'
				}
				this.$api[api](this.form).then(res => {
					this.$msg(res.msg)
					setTimeout(() => {
						uni.navigateBack()
					}, 1000)
				})
			},
			setgender() { //性别
				let that = this
				let itemList = ['男', '女', '保密']
				uni.showActionSheet({
					itemList,
					success(res) {
						that.form.gender = itemList[res.tapIndex]
					}
				})
			},
			geteducation() { //获取学历
				this.$api.education(this.form).then(res => {
					this.educationL = res.data
				})
			},
			seteducation(e) { //学历
				let that = this
				console.log(e);
				that.form.education = e[0].label
				// let itemList = ['小学', '初中', '高中', '大学', '研究生']
				// uni.showActionSheet({
				// 	itemList,
				// 	success(res) {
				// 		that.form.education = itemList[res.tapIndex]
				// 	}
				// })
			},
			setTime(e) {
				console.log(e);
				this.form.birthday = "" + e.year + '-' + e.day + '-' + e.month
			},
			setTimeRz(e) {
				console.log(e);
				this.form.estimated_entry_time = "" + e.year + '-' + e.day + '-' + e.month
			},
		}
	}
</script>

<style lang="scss">
	// /deep/.uni-input-wrapper{
	// 	text-align: right;
	// }
</style>
